#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

class segment_tree {
	vector<int> len, pre, suf, change;
	vector<bool> isupdate;

	void lazy(int i, int v, int n)
	{
		len[i] = pre[i] = suf[i] = v == 0 ? n : 0;
		change[i] = v;
		isupdate[i] = true;
	}

	void up(int i, int ln, int rn)
	{
		int l = i << 1, r = i << 1 | 1;
		len[i] = max({len[l], len[r], suf[l] + pre[r]});
		pre[i] = len[l] == ln ? pre[l] + pre[r] : pre[l];
		suf[i] = len[r] == rn ? suf[l] + suf[r] : suf[r];
	}

	void down(int i, int ln, int rn)
	{
		if (isupdate[i]) {
			lazy(i << 1, change[i], ln);
			lazy(i << 1 | 1, change[i], rn);
			isupdate[i] = false;
		}
	}

	void build(int l, int r, int i)
	{
		if (l == r) {
			len[i] = pre[i] = suf[i] = 1;
		} else {
			int mid = (l + r) >> 1;
			build(l, mid, i << 1);
			build(mid + 1, r, i << 1 | 1);
			up(i, mid - l + 1, r - mid);
		}
	}

    public:
	segment_tree(int n) : len(n << 2, 0), pre(n << 2, 0), suf(n << 2, 0), change(n << 2, 0), isupdate(n << 2, false)
	{
                build(1, n, 1);
	}

        void update(int jobl, int jobr, int v, int l, int r, int i)
        {
                if(jobl <= l && r <= jobr){
                        lazy(i, v, r - l + 1);
                }else{
                        int mid = (l + r) >> 1;
                        down(i, mid - l + 1, r - mid);
                        if(jobl <= mid){
                                update(jobl, jobr, v, l, mid, i << 1);
                        }
                        if(mid < jobr){
                                update(jobl, jobr, v, mid + 1, r, i << 1 | 1);
                        }
                        up(i, mid - l + 1, r - mid);
                }
        }

        int query(int x, int l, int r, int i)
        {
                if(l == r){
                        return l;
                }

                int mid = (l + r) >> 1;
                down(i, mid - l + 1, r - mid);
                if(len[i << 1] >= x){
                        return query(x, l, mid, i << 1);
                }

                if(suf[i << 1] + pre[i << 1 | 1] >= x){
                        return mid - suf[i << 1] + 1;
                }

                return query(x, mid + 1, r, i << 1 | 1);
        }

        int query()
        {
                return len[1];
        }
};

int main()
{
	int n, m, left;
	cin >> n >> m;
        segment_tree sgt(n);

        for(int i = 0, op, x, y; i < m; i++){
                cin >> op;
                if(op == 1){
                        cin >> x;
                        if(sgt.query() >= x){
                                left = sgt.query(x, 1, n, 1);
                                sgt.update(left, left + x - 1, 1, 1, n, 1);
                        }else{
                                left = 0;
                        }
                        cout << left << endl;
                }else{
                        cin >> x >> y;
                        sgt.update(x, x + y - 1, 0, 1, n, 1);
                }

        }
	return 0;
}